﻿using BigEgg.Framework.Applications.ViewModels;
using System.Xml.Serialization;

namespace FMStudio.Documents
{
    /// <summary>
    /// Abstract base class for a IDocument implementation.
    /// </summary>
    public abstract class Document : DataModel, IDocument
    {
        #region Fields
        private string filePath;
        private bool isModified;
        #endregion


        /// <summary>
        /// Initializes a new instance of the <see cref="Document" /> class.
        /// </summary>
        /// <param name="forceSave">A flag that indicating whether force save this document, no matter is modified.</param>
        public Document(bool forceSave)
        {
            this.ForceSave = forceSave;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Document" /> class.
        /// </summary>
        public Document()
            : this(false)
        {
        }


        #region Properties
        /// <summary>
        /// Gets or sets the file path of this document.
        /// </summary>
        [XmlIgnore()]
        public string FilePath
        {
            get { return this.filePath; }
            set
            {
                if (this.filePath != value)
                {
                    this.filePath = value;
                    RaisePropertyChanged("FilePath");
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this document is modified.
        /// </summary>
        [XmlIgnore()]
        public bool IsModified
        {
            get { return this.isModified; }
            set
            {
                if (this.isModified != value)
                {
                    this.isModified = value;
                    RaisePropertyChanged("IsModified");
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether force save this document, no matter is modified.
        /// </summary>
        [XmlIgnore()]
        public bool ForceSave { get; protected set; }
        #endregion
    }
}
